package com.wy.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected HttpSession session;
	
	/**
	 * get request
	 * @return HttpServletRequest
	 */
	public HttpServletRequest getRequest(){
		if(request ==null){
			return ServletActionContext.getRequest();
		}
		return request;
	}
	/**
	 * get response
	 * @return HttpServletResponse
	 */
	public HttpServletResponse getResponse(){
		if(response == null){
			return ServletActionContext.getResponse();
		}
		return response;
	}
	/**
	 * get session
	 * @return HttpSession
	 */
	public HttpSession getSession(){
		if(session == null){
			return getRequest().getSession();
		}
		return session;
	}
	
}
